const ThreeJsModule = {
  _sky: {module: null, path: 'three/examples/jsm/objects/Sky.js'},
  _css2DRenderer: {module: null, path: 'three/examples/jsm/renderers/CSS2DRenderer.js'},
  _css3DRenderer: {module: null, path: 'three/examples/jsm/renderers/CSS3DRenderer.js'},
  _orbitControls: {module: null, path: 'three/examples/jsm/controls/OrbitControls.js'},
  _firstPersonControls: {module: null, path: 'three/examples/jsm/controls/FirstPersonControls.js'},
  _pointerLockControls: {module: null, path: 'three/examples/jsm/controls/PointerLockControls.js'},
  _effectComposer: {module: null, path: 'three/examples/jsm/postprocessing/EffectComposer.js'},
  _outlinePass: {module: null, path: 'three/examples/jsm/postprocessing/OutlinePass.js'},
  _unrealBloomPass: {module: null, path: 'three/examples/jsm/postprocessing/UnrealBloomPass.js'},
  _renderPass: {module: null, path: 'three/examples/jsm/postprocessing/RenderPass.js'},
  _shaderPass: {module: null, path: 'three/examples/jsm/postprocessing/ShaderPass.js'},
  _fxaaShader: {module: null, path: 'three/examples/jsm/shaders/FXAAShader.js'},
  _mtlLoader: {module: null, path: 'three/examples/jsm/loaders/MTLLoader.js'},
  _objLoader: {module: null, path: 'three/examples/jsm/loaders/OBJLoader.js'},
  _gltfLoader: {module: null, path: 'three/examples/jsm/loaders/GLTFLoader.js'},
  _fbxLoader: {module: null, path: 'three/examples/jsm/loaders/FBXLoader.js'},
  _dracoLoader: {module: null, path: 'three/examples/jsm/loaders/DRACOLoader.js'},
  _mmdLoader: {module: null, path: 'three/examples/jsm/loaders/MMDLoader.js'},
  _tween: {module: null, path: 'three/examples/jsm/libs/tween.module.min.js'},
  _gui: {module: null, path: 'three/examples/jsm/libs/dat.gui.module.js'},
  _html2canvas: {module: null, path: 'html2canvas'},
  _firstPersonCameraControls: {module: null, path: './js/control/firstPersonCameraControls.js'},
  _firstPersonCameraControl: {module: null, path: './js/control/firstPersonCameraControl.js'},
  _thirdPersonCameraControl: {module: null, path: './js/control/thirdPersonCameraControl.js'},
  get Sky() {
    return importModule(this._sky).then((module)=> {return module.Sky})
  },
  get CSS2DRenderer() {
    return importModule(this._css2DRenderer).then((module)=> {return module.CSS2DRenderer})
  },

  get CSS2DObject() {
    return importModule(this._css2DRenderer).then((module)=> {return module.CSS2DObject})

  },

  get CSS3DRenderer() {
    return importModule(this._css3DRenderer).then((module)=> {return module.CSS3DRenderer})
  },

  get CSS3DObject() {
    return importModule(this._css3DRenderer).then((module)=> {return module.CSS3DObject})
  },

  get OrbitControls() {
    return importModule(this._orbitControls).then((module)=> {return module.OrbitControls})
  },

  get FirstPersonControls() {
    return importModule(this._firstPersonControls).then((module)=> {return module.FirstPersonControls})
  },

  get PointerLockControls() {
    return importModule(this._pointerLockControls).then((module)=> {return module.PointerLockControls})
  },
  get EffectComposer() {
    return importModule(this._effectComposer).then((module)=> {return module.EffectComposer})
  },

  get OutlinePass() {
    return importModule(this._outlinePass).then((module)=> {return module.OutlinePass})
  },

  get UnrealBloomPass() {
    return importModule(this._unrealBloomPass).then((module)=> {return module.UnrealBloomPass})
  },

  get RenderPass() {
    return importModule(this._renderPass).then((module)=> {return module.RenderPass})
  },

  get ShaderPass() {
    return importModule(this._shaderPass).then((module)=> {return module.ShaderPass})
  },

  get FXAAShader() {
    return importModule(this._fxaaShader).then((module)=> {return module.FXAAShader})
  },

  get MTLLoader() {
    return importModule(this._mtlLoader).then((module)=> {return module.MTLLoader})
  },

  get OBJLoader() {
    return importModule(this._objLoader).then((module)=> {return module.OBJLoader})
  },

  get GLTFLoader() {
    return importModule(this._gltfLoader).then((module)=> {return module.GLTFLoader})
  },

  get FBXLoader() {
    return importModule(this._fbxLoader).then((module)=> {return module.FBXLoader})
  },

  get DRACOLoader() {
    return importModule(this._dracoLoader).then((module)=> {return module.DRACOLoader})
  },

  get MMDLoader() {
    return importModule(this._mmdLoader).then((module)=> {return module.MMDLoader})
  },

  get TWEEN() {
    return importModule(this._tween).then((module)=> {return module.TWEEN})
  },

  get GUI() {
    return importModule(this._gui).then((module)=> {return module.GUI})
  },

  get html2canvas() {
    return importModule(this._html2canvas).then((module)=> {return module.html2canvas})
  },

  get FirstPersonCameraControls() {
    return importModule(this._firstPersonCameraControls).then((module)=> {return module.FirstPersonCameraControls})
  },

  get FirstPersonCameraControl() {
    return importModule(this._firstPersonCameraControl).then((module)=> {return module.FirstPersonCameraControl})
  },

  get ThirdPersonCameraControl() {
    return importModule(this._thirdPersonCameraControl).then((module)=> {return module.ThirdPersonCameraControl})
  },
}


function importModule(moduleObj) {
  if (!moduleObj.module) {
    return import(moduleObj.path).then(module => {
      moduleObj.module = module;
      return moduleObj.module;
    }).catch(error => {
      console.error(`Error importing from ${moduleObj.path}:`, error);
    });
  }
  return Promise.resolve(moduleObj.module);
}

function requireModule(moduleObj) {
  if (!moduleObj.module) {
    try {
      moduleObj.module = require(moduleObj.path);
    } catch (error) {
      console.error(`Error importing from ${moduleObj.path}:`, error);
    }
  }
  return Promise.resolve(moduleObj.module);
}

export default ThreeJsModule;
